from APIs.baseAPI import BaseAPI
import requests

from common.config import ip


class LoginAPI(BaseAPI):
    def login(self,mydata=None):
        if not mydata:
            mydata = {'username': 'admin', 'password': '123456'}
        rr = requests.post(f'{ip}/login', data=mydata)
        print(rr.json())
            # print(rr.json()['code'])
            # return rr.json()['code']
        return rr.json()
    def gettoken(self):
        # t=self.login('admin','123456')
        mydata = {'username': 'admin', 'password': '123456'}
        t = self.login(mydata)
        tt=t['Admin-Token']
        print(tt)
        return tt



if __name__ == '__main__':
    l=LoginAPI()
    # l.login()
    # l.gettoken()
    # l.getcode()







